<?php

namespace Modules\Common\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Storage;

class AppController
{

    /**
     * apk检查更新
     * @param Request $request
     */
    public function checkVersion(Request $request){

        $dir = $files = dir(public_path() . '/apk');
        $appFileName = '';
        while (false !== ($h = $dir->read())){
            if(in_array($h,['.','..'])){
                continue;
            }
            $appFileName = $h;
        }

        $version = explode('_',trim($appFileName,'.apk'));
        $version = $version[1];

        $app = [
            'app_name'      => '青为WMS',
            'version'       => $version,
            'is_update'        => 1,
            'download_url'  => env('APP_URL') . '/apk/' . $appFileName,
        ];

        return $app;

    }

}
